home *** CD-ROM | disk | FTP | other *** search
/ F1 Licenseware / F1 Licenseware - Volume 1.iso / disks / 089a.dms / 089a.adf / example.lha / DrunkenDuncan.AMOS / DrunkenDuncan.amosSourceCode
AMOS Source Code  |  1992-02-26  |  3KB  |  116 lines

  1. ' ******************** 
  2. ' *  Drunken Duncan  * 
  3. ' * by Mike Richmond * 
  4. ' ******************** 
  5. '
  6. ' v1.00
  7. '
  8. ' Any similarities between this program and the editor of AMOSZINE are 
  9. ' commpletely deliberate.
  10. '
  11. ' Left to its own devices this program creates a sort of Pseudo-map, but 
  12. ' its movement is almost completely random.  Duncan (the drunkard) either
  13. ' goes straight on, turns left or turns right.  His basic aim is to go in
  14. ' a straight line.  By decreasing the DRUNKENESS variable you can alter
  15. ' the program so he is more likely to go in a straight line, or so he is 
  16. ' completely out of his head and basically goes where he wants. DRUNKENESS 
  17. ' should at least 2 if you want Duncan to be able to move in a straight
  18. ' line 
  19. '
  20. ' If you change the value of HIED to 1 then Duncan's travels are not 
  21. ' shown as a solid line but as a moving dot.  Actually, it looks quite 
  22. ' like a small fly (have you ever noticed how flies seem to fly in circles 
  23. ' just like Duncan does in this program?)  An interesting thought.   
  24. '
  25. ' This isn't just Drunken, this is a fully fledged FLY SIMULATOR.  Sim Fly,
  26. ' I might call it...   BUY SIM FLY AND CREATE REAL LIFE ON YOUR AMIGA! 
  27. '
  28. ' This program is totally pointless but provides an interesting example
  29. ' of ordered randomness
  30. '
  31. ' In time, Duncan will have walked over every pixel on the screen.  Quite
  32. ' a long time, I think!
  33. '
  34. ' Hold the left mouse button to return to the editor 
  35. '
  36. DRUNKENESS=5 : Rem smaller numbers=more drunk 
  37. HIED=0 : Rem if HIED=1 then a solid line is not drawn 
  38. '
  39. '
  40. '
  41. Screen Open 0,320,200,2,Lowres
  42. Palette $0,$FFF : Flash Off : Curs Off : Hide 
  43. X=Rnd(319) : Y=Rnd(199)
  44. ' Random start coordinates for Dunc. 
  45. RAND:
  46. DI=Rnd(8)
  47. If DI=0 Then Goto RAND
  48. ' A random start direvtion for Duncan
  49. '
  50. Ink 1
  51. Repeat 
  52.    OX=X : OY=Y
  53.    T=Rnd(DRUNKENESS)
  54.    If T=0 Then Dec DI
  55.    If T=1 Then Inc DI
  56.    ' A value of 0 or 1 turns him round.  Anything else and he continues 
  57.    ' in a straight line 
  58.    '
  59.    If DI<1 Then DI=1
  60.    If DI>8 Then DI=8
  61.    ' Make sure the direction he is rravelling in is valid 
  62.    '
  63.    If DI=1 Then Dec Y
  64.    If DI=2
  65.       Dec Y
  66.       Inc X
  67.    End If 
  68.    If DI=3 Then Inc X
  69.    If DI=4
  70.       Inc X
  71.       Inc Y
  72.    End If 
  73.    If DI=5 Then Inc Y
  74.    If DI=6
  75.       Inc Y
  76.       Dec X
  77.    End If 
  78.    If DI=7 Then Dec X
  79.    If DI=8
  80.       Dec X
  81.       Dec Y
  82.    End If 
  83.    ' Move Duncan
  84.    '
  85.    If X<0 Then X=319
  86.    If X>319 Then X=0
  87.    If Y<0 Then Y=199
  88.    If Y>199 Then Y=0
  89.    ' Wraparound screen
  90.    Ink 1 : Plot X,Y
  91.    ' Put Dunc. on the screen
  92.    '
  93.    If HIED=1
  94.       Ink 0
  95.       Plot OX,OY
  96.    End If 
  97.    ' If HIED=1 delete the old Duncan from the screen.  Unfortunately it 
  98.    ' looks like there are two dots because the screen is not double 
  99.    ' buffered.  Oh well...
  100.    '
  101. Until Mouse Key<>0
  102. '
  103. Cls 0
  104. Home : Cdown : Cdown : Cdown : Cdown : Cdown 
  105. Pen 1 : Centre "Drunken Duncan v1.00"
  106. Cdown : Cdown : Cdown : Cdown 
  107. Centre "Another great program from..."
  108. Cdown : Cdown : Cdown : Cdown 
  109. Centre "RipperSoft"
  110. Cdown : Cdown : Cdown : Cdown 
  111. Centre "Press mouse to return to editor"
  112. Wait 25
  113. Repeat 
  114. Until Mouse Key<>0
  115. Fade 2
  116. Edit